package com.example.wacoffee_manage.controller;

import com.example.wacoffee_manage.Service.loginService;
import com.example.wacoffee_manage.pojo.Employee;
import com.example.wacoffee_manage.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/login")
public class loginController {
    @Autowired
    private loginService loginService;
    @PostMapping
    public Result login(@RequestBody Employee employee) {
        log.info("login");
        employee=loginService.login(employee);
        if(employee==null)
            return Result.error("用户名或密码错误");
        return Result.success(employee);
    }
}
